    function formatCurrency(num) {
    	if(num!=null){
    		num = num.toString().replace(/\$|\,/g,'');
    	}
    	if(isNaN(num))
    	num = "0";
    	sign = (num == (num = Math.abs(num)));
    	num = Math.floor(num*100+0.50000000001);
    	cents = num%100;
    	num = Math.floor(num/100).toString();
    	if(cents<10)
    	cents = "0" + cents;
    	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
    	num = num.substring(0,num.length-(4*i+3))+','+
    	num.substring(num.length-(4*i+3));
    	return (((sign)?'':'-') + '$' + num + '.' + cents);
    }
    
    
    function ValidateCustomDate(d) {
        var match = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(d);
        if (!match) {
            // pattern matching failed hence the date is syntactically incorrect
            return false;
        }
        var month = parseInt(match[1], 10) - 1; // months are 0-11, not 1-12
        var day   = parseInt(match[2], 10);
        var year  = parseInt(match[3], 10);
        var date  = new Date(year, month, day);
        // now, Date() will happily accept invalid values and convert them to valid ones
        // therefore you should compare input month/day/year with generated month/day/year
        return date.getDate() == day && date.getMonth() == month && date.getFullYear() == year;
    }